

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.EventListener;

public class ToolListener extends AbstractAction {

  protected DrawingCanvas canvas;
  protected Tool tool;

  public ToolListener(String name, Icon icon, String tip,
		        DrawingCanvas canvas, Tool tool) {
    super(name);
    putValue(Action.DEFAULT, icon);
    putValue(Action.SHORT_DESCRIPTION, tip);
    setEnabled(tool != null);
    this.canvas = canvas; 
    this.tool = tool;
  } 

  public void actionPerformed(ActionEvent e) {
    canvas.setCurrentTool(tool);
  }

}
